#ifndef SOLUTION_H_
#define SOLUTION_H_
#include <vector>

using namespace std;

class Solution {
public:
	int maxArea(vector<int> &height) {
		// Start typing your C/C++ solution below
		// DO NOT write int main() function
		int curMax = 0;
		if(height.size() < 2)
			return 0;
		size_t left = 0,right = height.size()-1;
		while(left<right){
			int h = min(height[left],height[right]);
			int a = (right-left)*h;

			if(a > curMax)
				curMax = a;

			if(height[left] <= height[right]){
				while((++left<right)&&(height[left]<h));
			}
			else{
				while((left<--right)&&(height[right]<h));
			}
		}

		return curMax;
	}
};
#endif